 <%--
  *  File:    BunchnoManage.jsp
  *  @Author: KevinFan
  *  Date:    2011/8/2
  *
  *  Copyright (C) 2000 - 2012 Oval Technologies, Inc.
  *  All rights reserved.
  *
  *  This software is the confidential and proprietary information of Oval
  *  Technologies, Inc. ("Confidential Information").  You shall not
  *  disclose such Confidential Information and shall use it only in
  *  accordance with the terms of the license agreement you entered into
  *  with Oval.
 --%>
<%@ page import="java.text.DecimalFormat" %>
<%@ page import="java.lang.*" %>
<%@ page contentType = "text/html;charset=UTF-8" %>

 <%
   Category cat = Category.getInstance("jsp.BunchnoManage");
   String strModuleName = "TDR";
   String privilegeCode = "A0502";
   String contextPath = request.getContextPath();
 %>
 <%@ include file="/inc/CommonHeader.inc" %>
 <%@ include file="/inc/OvalLocationDefault.inc" %>
 <%@ include file="/rpt/ReportURL.inc" %>
 <html>
 <iframe name="summaryfrm" scrolling="no" frameborder="0" style="position:absolute; top:0px; left:0px; display:none;border:#909eff 1px solid;"></iframe>
 <head>
 <title>CustomerCollateEdit</title>
 <PageFlow:CheckPageFlow pageName="p_getbunchnodetailsummary"/>
 <%@ include file="/inc/CatchError.inc" %>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
 <script language="JavaScript" src="<%=contextPath %>/js/SummaryDivision.js"></script>
 <link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
 <script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
 <script language="JavaScript" src="<%=contextPath %>/js/Calendar.js"></script>
 <script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
 <script language="JavaScript" src="<%=contextPath %>/js/opal2/mootools.js"></script>
 <%@ include file="/inc/SummaryDivision.inc" %>
 <%@ include file="/inc/NewCalendar.inc" %>
 <%
   Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
   HashMap onehash = (HashMap)pageContext.getAttribute("onehash");
   if(totalsummary == null)totalsummary = new Vector();
   if(onehash == null)onehash = new HashMap();
   String strSkipto= (String)onehash.get("skipto");
   int n = totalsummary.size();
 %>
<script>
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform)return;
  if(errorflag == 1){
	alert("密码/监管码格式不正确！");
	return;
  }
  if(cform.serdetailtype.value!=4 && (cform.serproductid.value=="" || cform.serproductid.value==null) && cform.serdatacode.value.length==9){
	alert("请选择所查询产品！");
	return;
  }
  editform.action = "BunchnoSearch.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function page_toSearch(){
	if(!checkForm(document.cform))return;
	serdatacode = cform.serdatacode.value
	cform.seritmecode.value=serdatacode.substr(0,5);
	page_summary('search');
}

function page_change(){
	serdatatype = cform.serdetailtype.value;
	if(serdatatype==4){
		document.getElementById("hidtext1").style.display = "block";
		document.getElementById("hidtext2").style.display = "block";
		document.getElementById("hidtext3").style.display = "none";
		document.getElementById("hidtext4").style.display = "none";
		cform.serproductid.value="";
		cform.serproductcode.value="";
		cform.serproductname.value="";
		document.getElementById("td_set").style.width="50%";
		cform.serbatchno.command="notnull";
		check_porscode();
	}else{
		document.getElementById("hidtext1").style.display = "none";
		document.getElementById("hidtext2").style.display = "none";
		document.getElementById("td_set").style.width="60%";
		cform.serbatchno.command="";
		cform.serbatchno.value="";
		check_porscode();
	}
}

var isHidden;
function frm_select(e){
	isHidden = "block";
	var _target = getPosition(e);
    var _obj = document.getElementById("summaryfrm");
    _obj.style.left = _target.x;
    _obj.style.top = _target.y + e.clientHeight;
    _obj.style.height="300px";
    _obj.style.width="530px";
    _obj.style.zIndex = 5000;
    _obj.style.display = "block";
}
function getPosition(e) {
        var left = 0;
        var top = 0;
        while (e.offsetParent) {
            left += e.offsetLeft + (e.curentStyle? (parseInt(e.curentStyle.borderLeftWidth).NaN0()):0);
            top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
            e = e.offsetParent;
        }
        left += e.offsetLeft + (e.curentStyle ? (parseInt(e.curentStyle.borderLeftWidth)).NaN0() : 0);
        top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
        return {x:left, y:top};
}
function closeItemSelect(evt)
{
	var _obj = document.getElementById("summaryfrm");
	if(isHidden == "block"){
		isHidden = "none";
	}else{
		_obj.style.display = "none";
	}
	evt = evt || window.event;
        var _target = evt.target || evt.srcElement;
        if (!_target.getAttribute("Author") && _target != inputObj && _target != targetObj) {
            getObjById("Calendar").style.display = "none";
            getObjById("CalendarFrm").style.display = "none";
        }
}

function hiddenFrm(){
	document.getElementById("summaryfrm").style.display = "none";
}

document.onclick=closeItemSelect;   

function page_setProduct(id,code,name,price,spec){	
		cform.serproductid.value=id;
		cform.serproductcode.value=code;
		cform.serproductname.value=name;
	hiddenFrm();
}

var errorflag=0;
function check_porscode() 
{ 
	porscode = cform.serdatacode.value;
	datatype = cform.serdetailtype.value;
	obj1 = cform.serdetailtype;
	if(datatype==-1){
		alert("请先选择包装类型！");
		obj1.focus();
		return;
	}
	if(datatype==4){
		if(porscode!=""){
			var patrn = /^[0-9]{7}$/;
			if(!patrn.exec(porscode)) { 
				alert("密码格式应为7位数字！");
				errorflag=1;
				cform.serdatacode.focus();
			}else{
				errorflag=0;
			}
		}
	}else{
		if(porscode!=""){
			var patrn1 = /^[0-9]{20}$/; 
			var patrn2 = /^[0-9]{9}$/;
			if(!patrn1.exec(porscode) && !patrn2.exec(porscode)) { 
				alert("监管码格式应为20位或简写9位数字!");
				errorflag=1;
				cform.serdatacode.focus();
			}else{
				errorflag=0;
				if(patrn2.exec(porscode)){
					document.getElementById("hidtext3").style.display = "block";
					document.getElementById("hidtext4").style.display = "block";
					document.getElementById("td_set").style.width="40%";
				}else{
					document.getElementById("hidtext3").style.display = "none";
					document.getElementById("hidtext4").style.display = "none";
					document.getElementById("td_set").style.width="60%";
					cform.serproductid.value="";
					cform.serproductcode.value="";
					cform.serproductname.value="";
				}
			}
		}
	}
	
} 
</script>
 </head>
 <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
 <iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
 <form name="cform" method="post" action="<%=contextPath %>/Dispatcher"> 
	<input type="hidden" name="pagename" value="p_getbunchnodetailsummary">
    <input type="hidden" name="actionname"/>
	<input type="hidden" name="errortype"/>
	<input type="hidden" name="pageaction">
	<custom:hidden property="maxitem"/>
	<input type="hidden" name="maker" value="<custom:write property="userid" name="userinfo" scope="session"/>"/>
	<custom:hidden property="serbunchnotype"/>
 <%-- page location --%>
   <%@ include file="/inc/PageLocation.inc" %>
	   <table width="100%" cellspacing="0" cellpadding="0" border="0">
		<tr>
             <td>
				 <table width="100%" cellspacing="5" cellpadding="0" border="0">
						<tr>
						 <td class="td_right"><%="包装类型" +  label.getLabelName("L_Colon") %></td>
						 <td class="td_left">
							<custom:selectdic dictType="PackagType" property="serdetailtype" command="notnull" defaultValue="------" defaultValueCost="-1" label="L_PackageType" onchange="javascript:page_change();"/>
						 </td>
						 <td class="td_right" style="display:none" id="hidtext1"><%="批号" +  label.getLabelName("L_Colon") %></td>
						 <td class="td_left" style="display:none" id="hidtext2">
							<custom:text property="serbatchno" size="20" label="L_LotNumber"/>
						 </td>
						 <td class="td_right"><%="密码/监管码" +  label.getLabelName("L_Colon") %></td>
						 <td class="td_left">
							<custom:text property="serdatacode" size="25" command="notnull" label="L_PassWordSupervis" onchange="check_porscode()"/>
							<custom:hidden property="seritmecode"/>
						 </td>
						 <td class="td_right" style="display:none" id="hidtext3"><%= label.getLabelName("L_Product") + label.getLabelName("L_Colon") %></td>
                         <td class="td_left" style="display:none" id="hidtext4">
                             <custom:hidden property="serproductid"/>
							 <custom:text property="serproductcode" size="10" readonly="true" label="L_Product"/>
                             <a onclick="javascript:frm_select(this);"><custom:button property="buttoner" type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                             <custom:text property="serproductname" size="15" readonly="true" />
                         </td>
						 <td><a onclick="javascript:page_toSearch();"><img src="/oval/images/cn/go.gif" border="0" ></a></td>
						 <td id="td_set" class="td_left" width="60%">	
						 </td>
                       </tr>
                 </table>
              </td>
           </tr>        
           <tr>
             <td colspan="2">
			  <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
                 <tr class="deepblue-left">
                   <td class="title_center">产品编码</td>
                   <td class="title_center">产品名称</td>
                   <td class="title_center">批号</td>
                   <td class="title_center">密码/基药监管码</td>
                   <td class="title_center">物流类型</td>
                   <td class="title_center">发货日期</td>
                   <td class="title_center">出货方</td>
                   <td class="title_center">进货方</td>				   
				   <td class="title_center">包装类型</td>
				   <td class="title_center">数量级别</td>
				   <td class="title_center">拼装类型</td>
                 </tr>
				 <%if(strSkipto != null){%> 
				 <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='td-listrom'" class="td-listrom">
						 <td rowspan="<%=n+1%>"><custom:write name="onehash" property="prodcode" nbsp="true"/></td>
                         <td rowspan="<%=n+1%>"><custom:write name="onehash" property="prodname" nbsp="true"/></td>
                         <td rowspan="<%=n+1%>"><custom:write name="onehash" property="batchno" nbsp="true"/></td>
                         <td rowspan="<%=n+1%>"><custom:write name="onehash" property="datacode" nbsp="true"/></td>
						 <td><custom:write name="onehash" dictType="LogisticsType" property="batchnoype" nbsp="true"/></td>
                         <td><custom:write name="onehash" property="docdate" nbsp="true"/></td>
                         <td><custom:write name="onehash" property="skipfrom" nbsp="true"/></td>
						 <td><custom:write name="onehash" property="skipto" nbsp="true"/></td>
						 <td><custom:write name="onehash" dictType="PackagType" property="datatype" nbsp="true"/></td>
						 <td><custom:write name="onehash" dictType="QuantityLevel" property="qtytype" nbsp="true"/></td>
						 <td><custom:write name="onehash" dictType="AssemblyType" property="assemblytype" nbsp="true"/></td>
                 </tr>	
				 <%}%>
				 <%
                        String strClassType="";
                        int i = 0;
						HashMap hash = null; 
						String strVal = "";
                 %>
				 <logic:iterate id="onedetail" collection="<%= totalsummary %>" >
                 <%//show different colours in turns
                     if(i%2 == 1)
                         {
                             strClassType = "td-listrom";
                         }else{
                             strClassType = "none";
                         }
                     i++;
                 %>
					<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%= strClassType %>'"   class="<%= strClassType %>">
						<%if(strSkipto == null && i==1){%> 
						 <td rowspan="<%=n%>"><custom:write name="onedetail" property="prodcode" nbsp="true"/></td>
                         <td rowspan="<%=n%>"><custom:write name="onedetail" property="prodname" nbsp="true"/></td>
                         <td rowspan="<%=n%>"><custom:write name="onedetail" property="batchno" nbsp="true"/></td>
                         <td rowspan="<%=n%>"><custom:write name="onedetail" property="datacode" nbsp="true"/></td>
						<%}%>
						 <td><custom:write name="onedetail" dictType="LogisticsType" property="batchnoype" nbsp="true"/></td>
                         <td><custom:write name="onedetail" property="docdate" nbsp="true"/></td>
                         <td><custom:write name="onedetail" property="skipfrom" nbsp="true"/></td>
						 <td><custom:write name="onedetail" property="skipto" nbsp="true"/></td>
						 <td><custom:write name="onedetail" dictType="PackagType" property="datatype" nbsp="true"/></td>
						 <td><custom:write name="onedetail" dictType="QuantityLevel" property="qtytype" nbsp="true"/></td>
						 <td><custom:write name="onedetail" dictType="AssemblyType" property="assemblytype" nbsp="true"/></td>
                     </tr>
				 </logic:iterate>
		</table>
	</td>
	</tr>
</table>
</form>	
<script>
	document.summaryfrm.location.href = "<%=contextPath %>/tdr/datatypein/ProdSelectPop.jsp?maxitem=10&<%= OvalTools.randomURL() %>";
	if(cform.serdetailtype.value!=-1){
		if(cform.serdetailtype.value==4){
			document.getElementById("hidtext1").style.display = "block";
			document.getElementById("hidtext2").style.display = "block";
			document.getElementById("td_set").style.width="50%";
		}else{
			if(cform.serdatacode.value.length==9){
				document.getElementById("hidtext3").style.display = "block";
				document.getElementById("hidtext4").style.display = "block";
				document.getElementById("td_set").style.width="40%";
				cform.serbatchno.command="";
			}
		}
	}
</script>
</body>
</html>


